import { getBaseUrl } from '@/services/urlconst';
import { requestFunComponFiex } from '@/utils';
import { useRequest } from 'umi';

const baseUrl = getBaseUrl();
/**
 * 作废接口
 * @param cancelModalCall
 * @returns
 */
const cancelModalRequest = (cancelModalCall: (res: any) => void, requestType: string, requestUrlStr: string) => {
  const cancelModal = useRequest(
    (params: any) => {
      let bodyParams: any = {
        ...params,
      };
      let personUrl = `${baseUrl}${requestUrlStr}`;
      return requestFunComponFiex(requestType, personUrl, bodyParams);
    },
    {
      manual: true,
      onSuccess: cancelModalCall,
    },
  );

  return {
    cancelModalRun: cancelModal?.run,
    cancelModalLoading: cancelModal?.loading,
  };
};

export { cancelModalRequest };
